﻿/*******************************************************************************
 * AAEngine
 * Copyright (c) 2010 Mike Jarosch
 *
 * Original source PushButton Engine:
 * Copyright (C) 2009 PushButton Labs, LLC
 * For more information see http://www.pushbuttonengine.com
 *
 * This file is licensed under the terms of the MIT license, which is included
 * in the "MIT License.txt" file at the root directory of this SDK.
 ******************************************************************************/

using System.Xml.Linq;

namespace AAEngine.Engine.Serialization
{
    /// <summary>
    /// Provides an interface for objects to override the default serialization
    /// behavior.
    /// </summary>
    /// <remarks>Any class implementing this interface will automatically have its
    /// serialize and deserialize methods called in place of the default serialization
    /// methods on the Serializer class.</remarks>
    public interface ISerializable
    {
        /// <summary>
        /// serializes the object to XML. This should not include the main tag
        /// defining the class itself.
        /// </summary>
        /// <param name="xml">The xml object to which the serialization of this class should
        /// be added. This xml object is a single tag containing the main class definition,
        /// so only children of this class should be added to it.</param>
        void Serialize(XElement xml);

        /// <summary>
        /// deserializes the object from xml. The format of the xml passed is custom,
        /// depending on the way the object was serialized with the serialize method.
        /// </summary>
        /// <param name="xml">The xml containing the serialized definition of the class.</param>
        /// <returns>The deserialized object. Usually 'this' should be returned, but in
        /// some cases it may be useful to return something else.</returns>
        object Deserialize(XElement xml);
    }
}
